/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86187
 * Date: 2022-04-15
 * Time: 11:16
 */

//求某数的二进制中1的个数

public class Test_4_15 {

    public static int RetBitNum(int x) {
        int num=0;
        for (int i=0;i<=31;++i) {
            if(((x>>i) & 1 ) == 1)
                num++;
        }
        return num;
    }

    public static void main(String[] args) {

        int x = -1;
        int answer = RetBitNum(x);
        System.out.println(answer);
    }
}
